package com.example.bbang.mapper;

import com.example.bbang.entity.Order;
import com.example.bbang.entity.Shenshu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface ShenshuMapper {
    @Insert("INSERT INTO `shenshu` ( `shenshu`, `username`,`time`,`bname`, `who`, " +
            "`orderid`, `img`, `whoStatus`) " +
            "VALUES (#{shenshu},#{username},#{time},#{bname},#{who},#{orderid}," +
            "#{img},#{whoStatus});")
    @Transactional
    void  add(Shenshu shenshu);


    //模搜分页
    @Select("select * from `shenshu` where shenshu like CONCAT('%',#{shenshu},'%')   limit #{pageNum},#{pageSize}")
    @Transactional
    List<Shenshu> findPageBySenshu(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize, @Param("shenshu") String shenshu);

    //根据id
    @Select("select * from `shenshu` where shenshuid=#{shenshuid} ")
    @Transactional
    List<Shenshu> findPageBySenshuID(@Param("shenshuid") Integer shenshuid);

    @Delete("delete from `shenshu` where shenshuid=#{shenshuid}")
    void deleteById(Shenshu shenshu);

    @Select("SELECT COUNT(*) AS row_count FROM `shenshu`")
    Integer getShenshuCount();
}
